<template>
  <div class="data">
    <div class="text">截止{{getDate()}}全国数据统计</div>
    <div class="list">
      <div class="info">
        <div>较昨日<span style="color: red">{{setDataFormat(setData(dataObj.currentConfirmedIncr))}}</span></div>
        <div style="color: red">{{ setData(dataObj.currentConfirmedCount) }}</div>
        <div>现存确诊</div>
      </div>
      <div class="info">
        <div>较昨日<span style="color: orange">{{ setDataFormat(setData(dataObj.suspectedIncr)) }}</span></div>
        <div style="color: orange">{{ setData(dataObj.suspectedCount) }}</div>
        <div>境外输入</div>
      </div>
      <div class="info">
        <div>较昨日<span style="color: saddlebrown">{{ setDataFormat(setData(dataObj.seriousIncr)) }}</span></div>
        <div style="color: saddlebrown">{{ setData(dataObj.seriousCount) }}</div>
        <div>现存无症状</div>
      </div>
      <div class="info">
        <div>较昨日<span style="color: #770404">{{ setDataFormat(setData(dataObj.confirmedIncr)) }}</span></div>
        <div style="color: #770404">{{ setData(dataObj.confirmedCount) }}</div>
        <div>累计确诊</div>
      </div>
      <div class="info">
        <div>较昨日<span style="color: #050579">{{ setDataFormat(setData(dataObj.deadIncr)) }}</span></div>
        <div style="color: #050579">{{ setData(dataObj.deadCount) }}</div>
        <div>累计死亡</div>
      </div>
      <div class="info">
        <div>较昨日<span style="color: #024b02">{{ setDataFormat(setData(dataObj.curedIncr)) }}</span></div>
        <div style="color: #024b02">{{ setData(dataObj.curedCount) }}</div>
        <div>累计治愈</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
props:{
  dataObj:{
    type:Object,
    default:function (){
      return {}
    }
  }
},
  methods:{
  setDataFormat(string){
    if(string.charAt(0)!='-'){
      return '+'+string;
    }else{
      return string;
    }
  },
    setData(data){
    var result='';
    var abs='';
    if(data<0){
      data=Math.abs(data)
      abs='-'
    }
      while(data>1000){
        var r=data%1000;
        data=parseInt(data/1000);
        result=','+r;
      }
      result=abs+data+result;
      // console.log(result.charAt(0))
    return result;
    },
    getDate(){
      let date = new Date(+new Date() + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
      return date
    }
  }
}
</script>

<style lang="less" scoped>
.data{
  background-color: #fff;
  padding: 10px 20px;
  margin: 5px 0px;
  .text{
    padding-left: 10px;
    border-left: 4px solid orange;
    margin-left: 10px;
  }
  .list{
    width: 90%;
    margin-left: 25px;
    border:1px solid #eee ;
    box-shadow: 1px 2px #eee;
    overflow: hidden;
    .info{
      border-right: 1px solid #eee;
      padding-bottom: 10px;
      text-align: center;
      float: left;
      margin-top: 10px;
      width: 33%;
    }
  }
}
</style>

